Skip to content

prusalink: complete API client implementation - #13

Merged
akinbender merged 7 commits into
mainfrom
copilot/cleanup-code-quality
Jan 3, 2026
Merged

akinbender merged 7 commits into
mainfrom
copilot/cleanup-code-quality

Conversation

Copilot AI commented Jan 3, 2026 •

Copy link
Copy Markdown
Contributor

Completes the PrusaLink and Moonraker API clients per their published specs, stabilizing connections and adding coverage.

Changes Made

  • Implemented PrusaLink REST calls for version, info, status, storage listing, and file metadata retrieval with typed DTOs matching the spec.
  • Added authentication configuration (basic/digest via HttpClient handler) and lightweight retry handling for transient failures.
  • Mapped status responses into existing telemetry without changing UI, and return clear NotSupportedException for unsupported printer-control commands.
  • Implemented Moonraker REST interactions with auth, retries, telemetry polling, file listing, and gcode-backed controls (temps, homing, moves, fan/speed/flow, axis steps, PID/thermal tuning, print start, save-config).
  • Introduced an xUnit test project with stubbed HTTP handler tests covering connect, status mapping, file listing, and command endpoints for both PrusaLink and Moonraker.
  • Updated CI workflow to run the new unit test project (dotnet test MakerPrompt.Tests/MakerPrompt.Tests.csproj).

Testing

  • ✅ dotnet test MakerPrompt.Tests/MakerPrompt.Tests.csproj
Original prompt

You are a senior .NET maintainer performing a pre-merge cleanup pass on an
already-working codebase.

Goal:
Create a single, clean pull request that improves code quality and build health
WITHOUT changing runtime behavior or user-visible functionality.

This is a hygiene-only task.

────────────────────────────────────────────────────────────
SCOPE OF WORK
────────────────────────────────────────────────────────────

  1. Commented-out code

    • Remove commented-out blocks that are:
      • Dead
      • Experimental
      • Clearly abandoned
    • If code is intentionally kept for future work:
      • Replace with a TODO comment explaining intent
      • Do NOT leave large commented code blocks
  2. Build warnings

    • Fix compiler warnings where possible:
      • Nullable reference warnings
      • Unused variables / usings
      • Obsolete API usage (only if a drop-in replacement exists)
    • If a warning cannot be fixed safely:
      • Suppress it locally with justification
      • Do NOT suppress globally
  3. Code clarity improvements (non-functional)

    • Improve naming only if it does NOT affect public APIs
    • Add missing XML documentation where it improves understanding
    • Normalize formatting and style
    • Remove obvious duplication if behavior stays identical
  4. Safety constraints

    • NO behavior changes
    • NO logic changes
    • NO architectural refactors
    • NO public API breaking changes
    • NO dependency changes unless required to fix warnings

────────────────────────────────────────────────────────────
PROCESS REQUIREMENTS
────────────────────────────────────────────────────────────

  • Work incrementally and conservatively
  • Prefer deletion over modification
  • If unsure whether a change affects behavior: DO NOT make it
  • Keep diffs small and reviewable
  • Do not “optimize” anything

────────────────────────────────────────────────────────────
PULL REQUEST OUTPUT
────────────────────────────────────────────────────────────

You must:

  1. Create a single PR
  2. Use a clear title, e.g.:
    "Code cleanup: remove dead code and fix build warnings"
  3. Provide a concise PR description explaining:
    • What was cleaned
    • What was intentionally NOT changed
  4. Ensure:
    • Build passes
    • No new warnings
    • No test failures (if tests exist)

────────────────────────────────────────────────────────────
MENTAL MODEL
────────────────────────────────────────────────────────────

Act like:

  • A conservative open-source maintainer
  • Cleaning up before others start building on this code
  • Prioritizing trust and minimal risk over elegance

If a change feels even slightly risky, skip it.

Proceed carefully.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 3, 2026 16:01
Co-authored-by: akinbender <40242943+akinbender@users.noreply.github.com>
Co-authored-by: akinbender <40242943+akinbender@users.noreply.github.com>
Copilot AI changed the title [WIP] Clean up commented-out code and fix build warnings Code cleanup: remove dead code and quiet nullable warnings Jan 3, 2026
Copilot AI requested a review from akinbender January 3, 2026 16:07
@akinbender

Copy link
Copy Markdown
Owner

@copilot You are a senior full-stack engineer with expertise in:

  • HTTP API client implementation
  • TypeScript/JavaScript or C# (choose the language of the existing partial code)
  • OpenAPI / REST API patterns
  • Clean, minimal, non-breaking code

Context:

  • The project uses the PrusaLink API spec from: https://github.com/prusa3d/Prusa-Link-Web/tree/master/spec
  • The API defines endpoints for printer status, files, jobs, storage, etc.
  • A partial PrusaLink connection implementation already exists in the codebase.
  • Your task is to finish and stabilize this API connection implementation.
  • Do NOT add unrelated features.

Goals (in order):

  1. Complete the PrusaLink API client

    • Ensure all relevant endpoints in the spec (e.g., version/info, printer status, job status, upload/download, storage listing) are implemented.
    • Respect the OpenAPI structure (base URL, versioning, path patterns).
  2. Properly handle authentication

    • API keys or credentials from config should be used correctly.
    • Implement token storage and renewal if needed per the spec.
    • Use appropriate headers (Authorization, Content-Type, Accept).
  3. Error handling & stability

    • Provide consistent error messages
    • Retry common transient errors (timeouts, network drop)
  4. Add types / interfaces

    • Use the OpenAPI definitions to define typed responses
    • Ensure null safety where applicable
  5. Write minimal tests

    • For each major endpoint (e.g., status, printer info, job list)
    • Use mocks or stubbed API responses
  6. Do NOT change existing behavior

    • Avoid refactoring unrelated code
    • Avoid UI changes
    • Only adjust code to finish missing logic and fix obvious mistakes
  7. Produce a tidy PR

    • Title: prusalink: complete API client implementation
    • PR description should include:
      • What was implemented
      • What endpoints are now fully supported
      • What tests were added
      • Any assumptions made about authentication or API behavior
    • Ensure the build passes with no warnings from these changes

Constraints:

  • Use the API spec under spec/ as the source of truth
  • Do not invent new endpoints not present in the spec
  • Preserve existing coding patterns
  • Keep changes minimal and reviewable

Deliverables:

  • Fully working API client code
  • Types/interfaces matching the spec
  • Minimal coverage tests
  • A clean, self-contained pull request

Proceed methodically: analyze the partial code first, then implement missing endpoints, then add error handling and tests.

Co-authored-by: akinbender <40242943+akinbender@users.noreply.github.com>

Copilot AI commented Jan 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot You are a senior full-stack engineer with expertise in:

  • HTTP API client implementation
  • TypeScript/JavaScript or C# (choose the language of the existing partial code)...

Implemented the PrusaLink client per the published spec: added version/info/status/storage/files support with digest/basic auth configuration, light retries, and typed DTOs; unsupported printer-control commands now return explicit NotSupported messages. Added xUnit tests covering connect/status/file listing with a stubbed handler. Changes in 917d32f.

Copilot AI changed the title Code cleanup: remove dead code and quiet nullable warnings prusalink: complete API client implementation Jan 3, 2026
@akinbender

Copy link
Copy Markdown
Owner

@copilot now same deal for moonraker: https://moonraker.readthedocs.io/en/latest/external_api/introduction/

Copilot AI and others added 2 commits January 3, 2026 16:40
Co-authored-by: akinbender <40242943+akinbender@users.noreply.github.com>
Co-authored-by: akinbender <40242943+akinbender@users.noreply.github.com>

Copilot AI commented Jan 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot now same deal for moonraker: https://moonraker.readthedocs.io/en/latest/external_api/introduction/

Added Moonraker client coverage: endpoints for info/status/files, gcode-backed controls (temp, moves, speeds), print start, and retries/auth handling, plus xUnit tests with stubbed handler. Changes in 1bb33f0.

@akinbender

Copy link
Copy Markdown
Owner

@copilot you didnt add the test project to the workflows so that there is a test run

Co-authored-by: akinbender <40242943+akinbender@users.noreply.github.com>

Copilot AI commented Jan 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot you didnt add the test project to the workflows so that there is a test run

Added unit test execution to CI (dotnet test MakerPrompt.Tests/MakerPrompt.Tests.csproj) in build.yml so new tests run in the workflow. Changes in 658bf08.

@akinbender
akinbender marked this pull request as ready for review January 3, 2026 16:54
@akinbender
akinbender merged commit bb06127 into main Jan 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants